#include <cstdio>
#include <cstdlib>
using namespace std;

#define ARRAY_LENGTH 10

void print_array(int[], int);
void swap_element(int[], int, int);
void quick_sort(int[], int, bool);

int main()
{
    int array[ARRAY_LENGTH] = {0};
    int odd_array[ARRAY_LENGTH] = {0};
    int even_array[ARRAY_LENGTH] = {0};
    while (scanf(" %d", &array[0]) != EOF) {
        for (int i = 1; i < ARRAY_LENGTH; i++)
            scanf(" %d", &array[i]);
        
        int odd_num = 0, even_num = 0;
        for (int i = 0; i < ARRAY_LENGTH; i++) {
            if (array[i] % 2 == 0)
                even_array[even_num++] = array[i];
            else
                odd_array[odd_num++] = array[i];
        }

        // printf("odd num is %d, even num is %d\n", odd_num, even_num);
        quick_sort(odd_array, odd_num, false);
        quick_sort(even_array, even_num, true);
        print_array(odd_array, odd_num);
        print_array(even_array, even_num);
        printf("\n");
    }
}

void swap_element(int array[], int i, int j) 
{
    int temp;
    temp = array[i];
    array[i] = array[j];
    array[j] = temp;
}

void quick_sort(int array[], int num, bool increasing) 
{
    int i, last = 0;
    if (num <= 1)
        return;
    swap_element(array, 0, rand() % num);
    for (i = 1; i < num; i++) {
        if (increasing) {
            if (array[i] < array[0])
                swap_element(array, ++last, i);
        } else {
            if (array[i] > array[0])
                swap_element(array, ++last, i);
        }
    }

    swap_element(array, 0, last);
    quick_sort(array, last, increasing);
    quick_sort(array + last + 1, num - last - 1, increasing);
}

void print_array(int array[], int num) 
{
    for (int i = 0; i < num; i++) {
        printf("%d ", array[i]);
    }
}